use std::env::args;
use crate::utilty::{container_db, container_fs_dir_get, log_error, rm_dir_all, rm_file};

pub fn rm_container(mut image_name:String, container_name:String) {
    image_name.push_str("_");
    image_name.push_str(&container_name);
    let container_name = image_name.clone();
    let fs_dirs = container_fs_dir_get(image_name, container_name.clone());
    let db_file = container_db(container_name.clone());
    rm_dir_all(fs_dirs.container_dir.clone());
    rm_dir_all(fs_dirs.merge_dir.clone());
    rm_dir_all(fs_dirs.worker_dir.clone());
    rm_file(db_file);
}
pub fn rm(){
    let image_name = args().nth(2).expect("no image name");
    let container_name = args().nth(3).expect("no container name");
    let image_name = image_name.trim().to_string();
    let container_name = container_name.trim().to_string();
    if image_name.is_empty() || container_name.is_empty() {
        log_error("args count error".to_string());
        return;
    }
    rm_container(image_name, container_name);
}